import request from '@/utils/request'

// 流程结构
export function processStructure(params) {
  return request({
    url: '/api/v1/baqsj-order/process-structure',
    method: 'get',
    params
  })
}

// 新建流程
export function createWorkOrder(data) {
  return request({
    url: '/api/v1/baqsj-order/create',
    method: 'post',
    data
  })
}

export function updateWorkOrder(data) {
  return request({
    url: '/api/v1/baqsj-order/update',
    method: 'post',
    data
  })
}

export function draftWorkOrder(data) {
  return request({
    url: '/api/v1/baqsj-order/draft',
    method: 'post',
    data
  })
}

// 流程列表
export function workOrderList(params) {
  params.recycling = 0
  return request({
    url: '/api/v1/baqsj-order/list',
    method: 'get',
    params
  })
}

export function workOrderTodoList(params) {
  params.recycling = 0
  return request({
    url: '/api/v1/baqsj-order/list',
    method: 'get',
    params
  })
}

export function recyclingList(params) {
  params.recycling = 1
  return request({
    url: '/api/v1/baqsj-order/list',
    method: 'get',
    params
  })
}

export function checkWorkNo(data) {
  return request({
    url: '/api/v1/baqsj-order/checkNo',
    method: 'post',
    data
  })
}

// 处理流程
export function handleWorkOrder(data) {
  return request({
    url: '/api/v1/baqsj-order/handle',
    method: 'post',
    data
  })
}

// 结束流程
export function unityWorkOrder(params) {
  return request({
    url: '/api/v1/baqsj-order/unity',
    method: 'get',
    params
  })
}

// 转交流程
export function inversionWorkOrder(data) {
  return request({
    url: '/api/v1/baqsj-order/inversion',
    method: 'post',
    data
  })
}

// 催办流程
export function urgeWorkOrder(params) {
  return request({
    url: '/api/v1/baqsj-order/urge',
    method: 'get',
    params
  })
}

export function recallWorkOrder(params) {
  return request({
    url: '/api/v1/baqsj-order/recall',
    method: 'get',
    params
  })
}

// 主动接单
export function activeOrder(data, workOrderId) {
  return request({
    url: `/api/v1/baqsj-order/active-order/${workOrderId}`,
    method: 'put',
    data
  })
}

// 删除流程
export function deleteWorkOrder(workOrderId) {
  return request({
    url: `/api/v1/baqsj-order/delete/${workOrderId}`,
    method: 'delete'
  })
}

export function clearWorkOrder(processId) {
  return request({
    url: `/api/v1/baqsj-order/clear/${processId}`,
    method: 'delete'
  })
}

export function recyclingWorkOrder(workOrderId) {
  return request({
    url: `/api/v1/baqsj-order/recycling/${workOrderId}`,
    method: 'post'
  })
}

export function resumeWorkOrder(workOrderId) {
  return request({
    url: `/api/v1/baqsj-order/resume/${workOrderId}`,
    method: 'post'
  })
}

// 删除流程
export function reopenWorkOrder(id) {
  return request({
    url: `/api/v1/baqsj-order/reopen/${id}`,
    method: 'post'
  })
}
